import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import 'lib-flexible';

//rain-ui
import RainUI from '@/components/index'
Vue.use(RainUI)

//alloyfinger
import AlloyFinger from 'alloyfinger'
import AlloyFingerPlugin from 'alloyfinger/vue/alloy_finger_vue'

Vue.use(AlloyFingerPlugin,{
  AlloyFinger
})



// axios
import Request from '@/server/http'
import api from '@/server/api'
Vue.prototype.$Request = Request
Vue.prototype.$api = api

//util 全局组件
import utils from '@/store/util.ts'
Vue.use(utils)

//修改页面title
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {document.title = to.meta.title}
  /* 匹配路由权限 */
  const userInfo = sessionStorage.getItem('userInfo') || null //获取登录信息
  if (!userInfo && to.meta.auth) {
    next('/login')
  } else {
    next()
  }
})

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
